@import '../../style/themes';
@import '../../style/mixins';

@import './ain';

@mixin calendar() {
  @include reset-component();
  position: relative;
  display: flex;
  flex-direction: column;
  padding: $padding-xss $margin-sm;
  width: 360px;
  height: 340px;
  background: $calendar-bg;
  user-select: none;
  overflow: hidden;

  &_container-scroll {
    flex: 1;
  }

  &_container {
    height: 100%;
  }

  &_grid {
    display: grid;
    margin-right: -2px;
  }

  &_cell {
    position: relative;
    margin-bottom: 2px;
    margin-right: 2px;
    text-align: center;
    transition: color 400ms;
    cursor: default;

    &:hover {
      outline: 2px solid rgba($gray, 0.2);
      outline-offset: -2px;
    }

    &:active {
      outline-color: rgba($gray, 0.5);
    }

    &-in-range {
      background: rgba($primary-color, 0.15);
    }

    &-prev,
    &-next {
      color: rgba($text-color, 0.3);
    }

    &-selected {
      background: $primary-color;
      outline: 2px solid $bg;
      outline-offset: -4px;
      color: #fff;

      &:hover {
        outline: 2px solid $bg;
        outline-offset: -4px;
      }

      &:active {
        outline-color: rgba($gray, 0.5);
      }
    }

    &-this {
      color: $primary-color;
      font-weight: bold;
      text-decoration: underline;
    }

    &-selected#{&}-this {
      color: #fff;
    }

    &-disabled {
      color: rgba($text-color, 0.2);
      background: $calendar-disabled-bg;
      pointer-events: none;
    }
  }

  &_header {
    display: flex;
    align-items: center;
    font-size: 15px;

    &_title {
      flex: 1;
      padding-left: $padding-sm;
      line-height: 40px;
      opacity: 0.8;

      &:hover {
        opacity: 1;
        background: rgba($text-color, 0.02);
      }

      &:active {
        opacity: 0.6;
      }
    }
  }

  &_prev-btn,
  &_next-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 40px;
    margin: 0 1px;
    font-size: 1.5em;
    text-align: center;
    opacity: 0.8;
    transform: translateZ(0);

    &:hover {
      opacity: 1;
      background: rgba($text-color, 0.02);
    }

    &:active {
      opacity: 0.4;
    }
  }
}

.x-calendar {
  @include reset-component();
  @include calendar();

  &_week {
    grid-template-columns: repeat(7, 1fr);
    font-size: 12px;
    font-weight: normal;
    text-align: center;
  }

  &_weekday {
    height: 40px;
    line-height: 40px;
  }

  &_cell {
    height: 40px;
    line-height: 40px;
  }
}

.x-month-calendar {
  @include reset-component();
  @include calendar();

  &_cell {
    height: 65px;
    line-height: 65px;
  }
}
